package com.biu.billiards.controller;

import com.biu.billiards.model.vo.billiards.AddBilliardsVo;
import com.biu.billiards.model.vo.billiards.GetBilliardsVo;
import com.biu.billiards.model.vo.billiards.UpdateBilliardsVO;
import com.biu.billiards.model.vo.dy.DyGoodsVo;
import com.biu.billiards.model.vo.mqtt.OpenBilliardsVo;
import com.biu.billiards.model.vo.mqtt.OpenDeviceVo;
import com.biu.billiards.mqqts.MqttService;
import com.biu.billiards.response.BaseResponse;
import com.biu.billiards.response.RespGenerator;
import com.biu.billiards.service.IBilliardsService;
import com.biu.billiards.service.IDyService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Map;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xue
 * @since 2023-09-25
 */
@RestController
@RequestMapping()
public class BilliardsController {



    @Resource
    private IBilliardsService billiardsService;


    @Resource
    private IDyService dyService;

    @ApiOperation(value = "抖音验证开台")
    @PostMapping("/dyValid")
    public BaseResponse<Boolean> dyValid(@RequestBody DyGoodsVo dyGoodsVo) {
        return RespGenerator.returnOK(dyService.dyValid(dyGoodsVo));
    }


    @ApiOperation(value = "美团验证开台")
    @PostMapping("/mtValid")
    public BaseResponse<Boolean> mtValid(@RequestBody DyGoodsVo dyGoodsVo) {
        return RespGenerator.returnOK(dyService.mtValid(dyGoodsVo));
    }

    @ApiOperation(value = "开台球")
    @PostMapping("/openBilliards")
    public BaseResponse<Boolean> openBilliards(@RequestBody OpenBilliardsVo openBilliardsVo) {
        return RespGenerator.returnOK(billiardsService.openBilliards(openBilliardsVo));
    }


    @ApiOperation(value = "开关设备")
    @PostMapping("/openDeviceVo")
    public BaseResponse<Boolean> openDeviceVo(@RequestBody OpenDeviceVo openDeviceVo) {
        return RespGenerator.returnOK(billiardsService.openDevice(openDeviceVo));
    }




    @ApiOperation(value = "获取list台球数据")
    @PostMapping("/getBilliardsList")
    public BaseResponse<Map<String,Object>> getBilliardsList(@RequestBody GetBilliardsVo getBilliardsVo) {
        return RespGenerator.returnOK(billiardsService.getBilliardsList(getBilliardsVo));
    }


    @ApiOperation(value = "获取分页台球数据")
    @PostMapping("/getBilliardsPage")
    public BaseResponse<Map<String,Object>> getBilliardsPage(@RequestBody GetBilliardsVo getBilliardsVo) {

        return RespGenerator.returnOK(billiardsService.getBilliardsPage(getBilliardsVo));
    }


    @ApiOperation(value = "修改台球信息")
    @PutMapping("/updateBilliards")
    public BaseResponse<Boolean> updateBilliards(@RequestBody UpdateBilliardsVO updateBilliardsVO) {
        return RespGenerator.returnOK(billiardsService.updateBilliards(updateBilliardsVO));
    }


    @ApiOperation(value = "新增台球信息")
    @PostMapping("/addBilliards")
    public BaseResponse<Boolean> addBilliards(@RequestBody AddBilliardsVo addBilliardsVo) {

        return RespGenerator.returnOK(billiardsService.addBilliards(addBilliardsVo));
    }


    @ApiOperation(value = "删除台球信息")
    @DeleteMapping("/deleteBilliards")
    public BaseResponse<Boolean> deleteBilliards(@RequestParam("billiardsId") Integer billiardsId) {

        return RespGenerator.returnOK(billiardsService.deleteBilliards(billiardsId));
    }


}
